package com.zretc.dao;

import java.util.List;

import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import com.zretc.entity.Blog;

public interface BlogMapper {
	/**
	 * 根据blogid来查询blog信息
	 * 
	 * @param id
	 * @return
	 */
	@Select(value = "select id,blogtitle,content,authorid from blog where id = #{id}")
	@Results(value = { @Result(property = "id", column = "id", id = true),
			@Result(property = "title", column = "blogtitle"), @Result(property = "content", column = "content"),
			@Result(property = "author", column = "authorid", one = @One(select = "com.zretc.dao.AuthorMapper.selectAuthor")) })
	public Blog selectBlog(int id);

	@Select(value = "select id,blogtitle,content from blog where authorid = #{authorid}")
	@Results(value = { @Result(property = "id", column = "id", id = true),
			@Result(property = "title", column = "blogtitle"), @Result(property = "content", column = "content") })
	public List<Blog> selectBlogByAuthorId(int authroid);

}
